package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.domain.City;
import com.itheima.domain.Product;
import com.itheima.factory.MapperFactory;
import com.itheima.mapper.CityMapper;
import com.itheima.mapper.ProductMapper;
import com.itheima.service.CityService;
import com.itheima.utils.TransactionUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CityServiceImpl  implements CityService {
    @Override
    public List<City> findAll() {
        //根据工厂化对象获取session的对象
        SqlSession session = MapperFactory.getSqlSession();

        //根据session对象获取接口的实现类对象
        CityMapper mapper = session.getMapper(CityMapper.class);

        //调用接口实现类的方法
        List<City> list = mapper.findAll();

        //释放资源
        TransactionUtil.close(session);
        return list;
    }
}
